﻿#ifndef TM_POINTLINEITEM_H
#define TM_POINTLINEITEM_H

#include <QGraphicsItem>
#include "common.h"

struct LineToMess{
public:
    QVariantMap map;
};

class TM_PointLineItem:public QGraphicsItem
{
public:
    TM_PointLineItem(QPointF start,QPointF end,QString startItemId,QString endItemId,int lineType = 1,QGraphicsItem *parent=0);
    ~TM_PointLineItem();

public:
    QGraphicsPolygonItem   *PolygonItem = NULL;

    int m_LineDirection = 1;//1:start->end  2:end->start  3双向

    QString m_startItemId;
    QString m_endItemId;

    QPointF m_start;
    QPointF m_start_bezier;
    QPointF m_end;
    QPointF m_end_bezier;

    LineToMess m_startToend;
    LineToMess m_endTostart;

    QList<QPointF> m_PointList;

    double m_K = 1;
    double m_B = 0;

    QPointF data1;
    QPointF data2;

    double m_len;
    double m_jiaodu = 300;

    double m_scale = 1;
    void setLineDerice(int Direct);
    void update_bezierData();
    void setBezierPoint(QPointF  start,QPointF  end,QPointF  bezierstart,QPointF  bezierend);
    void setStartPoint(QPointF  start,double ScaleValue = 1);
    void setEndPoint(QPointF  end,double ScaleValue = 1);
    void setStart_BezierPoint(QPointF  start,double ScaleValue = 1);
    void setEnd_BezierPoint(QPointF  end,double ScaleValue = 1);
    void setLine_Parameter(QString type = "",QString data = "");
protected:
    QRectF boundingRect()const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
};
#endif // TM_POINTLINEITEM_H
